﻿using System;
using System.Collections.Generic;
using WickedFlame.Core.Shapes;
using System.Windows;

namespace WickedFlame.Util.Data
{
    [Serializable]
    public class SerializableImage
    {
        byte[] bytes;
        double x=0.0;
        double y=0.0;

        public ImageShape Source
        {
            get
            {
                if (bytes == null)
                    throw new Exception("Source was not defined");

                ImageShape s = new ImageShape();
                s.Image = s.ImageFromBuffer(bytes);
                s.Rectangle = new Rect(x, y, s.Image.Width, s.Image.Height);

                return s;
            }
            set
            {
                bytes = value.BufferFromImage(value.Image);

                x = value.Rectangle.X;
                y = value.Rectangle.Y;
            }
        }

        
    }
}
